package com.link2room.jetfire.facade.impl;

import com.link2room.bumblebee.dto.param.base.PmsReservationOptionParamDto;
import com.link2room.bumblebee.dto.result.base.PmsReservationOptionDto;
import com.link2room.common.constant.BaseConstant;
import com.link2room.common.constant.DefaultValue;
import com.link2room.common.dto.result.base.MemberSessionDto;
import com.link2room.common.dto.threadlocal.ApiThreadLocal;
import com.link2room.common.dto.threadlocal.BaseThreadLocal;
import com.link2room.common.entity.BaseEntity;
import com.link2room.common.enums.BaseSysExceptionEnum;
import com.link2room.common.exception.SysException;
import com.link2room.common.jpa.condition.ConditionDetail;
import com.link2room.common.jpa.condition.L2RCondition;
import com.link2room.common.jpa.criteria.CriteriaUtil;
import com.link2room.common.jpa.result.QueryResult;
import com.link2room.common.service.ICommonService;
import com.link2room.common.util.*;
import com.link2room.enums.exception.JetfireSysExceptionEnum;
import com.link2room.jetfire.constant.ReservationConstant;
import com.link2room.jetfire.dto.param.api.ReservationBaseApiParamDto;
import com.link2room.jetfire.dto.param.api.WxPayOrderApiParamDto;
import com.link2room.jetfire.dto.param.base.ReservationParamDto;
import com.link2room.jetfire.dto.result.base.*;
import com.link2room.jetfire.entity.*;
import com.link2room.jetfire.exception.JetfireException;
import com.link2room.jetfire.facade.IReservationApiFacadeService;
import com.link2room.jetfire.feign.bumblebee.PmsReservationOptionFeignService;
import com.link2room.jetfire.feign.soundwave.PmsReservationFeignService;
import com.link2room.jetfire.feign.trailbreaker.PrepayFeignService;
import com.link2room.jetfire.service.IReservationService;
import com.link2room.optimus.constant.BaseRateplanConstant;
import com.link2room.optimus.dto.result.base.L2RCancelRuleBaseDto;
import com.link2room.optimus.dto.result.base.L2RCancelRuleDto;
import com.link2room.trailbreaker.constant.Pay;
import com.link2room.trailbreaker.dto.paramDto.PrePayParamDto;
import com.link2room.trailbreaker.dto.result.base.PrepayResDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;

/**
 * Created by sss on 2016/9/20.
 */
@Component("reservationApiFacadeService")
public class ReservationApiFacadeServiceImpl implements IReservationApiFacadeService {

    @Autowired
    private PrepayFeignService prepayFeignService;

    @Resource
    private IReservationService reservationService;

    @Resource
    private ICommonService commonService;

    @Autowired
    private PmsReservationFeignService pmsReservationFeignService;

    @Autowired
    private PmsReservationOptionFeignService pmsReservationOptionFeignService;

    /**
     * API取消订单
     * @param reservationBaseApiParamDto
     * @throws Exception
     */
    @Override
    public void cancelReservationBase(ReservationBaseApiParamDto reservationBaseApiParamDto)throws Exception {
        MemberSessionDto memberSession = ApiThreadLocal.getMemberSessionThreadLocal();

        if (memberSession != null) {
            L2RCondition l2RCondition = new L2RCondition();
            l2RCondition.setAndConditions(new ConditionDetail[]{
                    new ConditionDetail(BaseEntity.BaseEntity_.id.toString(), CriteriaUtil.Operator.EQ, reservationBaseApiParamDto.getId()),
                    new ConditionDetail(ReservationBase.ReservationBase_.resSta.toString(), CriteriaUtil.Operator.EQ, ReservationConstant.RESSTA.R)
            });
            l2RCondition.setOrConditions(new ConditionDetail[]{
                    new ConditionDetail(ReservationBase.ReservationBase_.rsvMobile.toString(), CriteriaUtil.Operator.EQ,memberSession.getMobile()),
                    new ConditionDetail(ReservationBase.ReservationBase_.openid.toString(), CriteriaUtil.Operator.EQ, memberSession.getOpenid()),
                    new ConditionDetail(ReservationBase.ReservationBase_.memberNo.toString(), CriteriaUtil.Operator.EQ, memberSession.getMemberNo())

            });
            QueryResult<ReservationBase> rbResult = commonService.findAllByCondition(ReservationBase.class, l2RCondition);
            if (rbResult.getResultlist() != null && rbResult.getResultlist().size() == 1) {
                ReservationBase rb = rbResult.getResultlist().get(0);
                reservationService.cancelReservation(rb);
            }
        }
    }
    /**
     * 获取订单列表
     * @param reservationBaseApiParamDto
     * @return
     * @throws Exception
     */
    @Override
    public QueryResult<ReservationDto> listReservationFroApi(ReservationBaseApiParamDto reservationBaseApiParamDto)throws Exception{
        MemberSessionDto memberSession= ApiThreadLocal.getMemberSessionThreadLocal();
        String mobile=memberSession.getMobile();
        if(memberSession!=null) {
            L2RCondition l2RCondition=new L2RCondition();
            l2RCondition.setAndConditions(new ConditionDetail[]{
                    new ConditionDetail(BaseEntity.BaseEntity_.lhotelGroupCode.toString(), CriteriaUtil.Operator.EQ,reservationBaseApiParamDto.getLhotelGroupCode()),
                    new ConditionDetail(BaseEntity.BaseEntity_.lhotelCode.toString(), CriteriaUtil.Operator.EQ,reservationBaseApiParamDto.getLhotelCode()),
                    new ConditionDetail(ReservationBase.ReservationBase_.resSta.toString(), CriteriaUtil.Operator.EQ,reservationBaseApiParamDto.getResSta())
            });
            l2RCondition.setOrConditions(new ConditionDetail[]{
                    new ConditionDetail(ReservationBase.ReservationBase_.rsvMobile.toString(), CriteriaUtil.Operator.EQ,mobile),
                    new ConditionDetail(ReservationBase.ReservationBase_.openid.toString(), CriteriaUtil.Operator.EQ, memberSession.getOpenid()),
                    new ConditionDetail(ReservationBase.ReservationBase_.memberNo.toString(), CriteriaUtil.Operator.EQ, memberSession.getMemberNo())

            });

            HashMap<String,String> sortMap=new HashMap<>();
            sortMap.put(BaseEntity.BaseEntity_.createDatetime.toString(),CriteriaUtil.DESC);
            QueryResult<ReservationBase> rbResult;
            if(StringUtil.isNotBlank(mobile)||StringUtil.isNotBlank(memberSession.getOpenid())||StringUtil.isNotBlank(memberSession.getMemberNo())){
                rbResult= commonService.findAllByCondition(ReservationBase.class, l2RCondition,reservationBaseApiParamDto.getCurrentPage(),reservationBaseApiParamDto.getPageSize(),sortMap,null);
            }else {
                throw new JetfireException(BaseSysExceptionEnum.MEMBER_SESSION_LOSE);
            }
            if(rbResult.getResultlist()!=null&&rbResult.getResultlist().size()>0){
                List<String> l2rNos=new ArrayList<>();
                List<ReservationDto> reservationDtoList=new ArrayList<>();
                for(ReservationBase rb:rbResult.getResultlist()){
                    ReservationDto reservationDto=new ReservationDto();
                    reservationDto.setReservationBaseDto(ClassConverUtil.copyPropertiesToDto(rb,ReservationBaseDto.class,false));
                    l2rNos.add(rb.getL2RNo());
                    reservationDtoList.add(reservationDto);
                }
                L2RCondition l2RCondition1=new L2RCondition();
                l2RCondition1.setAndConditions(new ConditionDetail[]{
                        new ConditionDetail(BaseEntity.BaseEntity_.lhotelGroupCode.toString(), CriteriaUtil.Operator.EQ,reservationBaseApiParamDto.getLhotelGroupCode()),
                        new ConditionDetail(ReservationAccount.ReservationAccount_.l2RNo.toString(), CriteriaUtil.Operator.IN,l2rNos)
                });
                QueryResult<ReservationAccount> raResult= commonService.findAllByCondition(ReservationAccount.class, l2RCondition1);
                if(raResult.getResultlist()!=null&&raResult.getResultlist().size()>0){
                    for(ReservationDto rv:reservationDtoList){
                        for(ReservationAccount ra:raResult.getResultlist()){
                            if(ra.getL2RNo().equals(rv.getReservationBaseDto().getL2RNo())){
                                rv.setReservationAccountDto(ClassConverUtil.copyPropertiesToDto(ra,ReservationAccountDto.class,false));
                            }
                        }
                    }
                }
                QueryResult<ReservationDto> reservationDtoQueryResult=new QueryResult<>();
                reservationDtoQueryResult.setResultlist(reservationDtoList);
                reservationDtoQueryResult.setTotalrecord(rbResult.getTotalrecord());
                reservationDtoQueryResult.setCurrentPage(rbResult.getCurrentPage());
                return reservationDtoQueryResult;
            }else {
                return null;
            }
        }else{
            return null;
        }
    }

    /**
     * 获取订单详情
     * @param reservationBaseApiParamDto
     * @return
     * @throws Exception
     */
    @Override
    public ReservationDto getReservationForApi(ReservationBaseApiParamDto reservationBaseApiParamDto)throws Exception{
        Date now=reservationBaseApiParamDto.getNow();
        MemberSessionDto memberSession= ApiThreadLocal.getMemberSessionThreadLocal();
        ReservationBase queryrb=new ReservationBase();
        queryrb.setId(reservationBaseApiParamDto.getId());
        String cancelFlag=DefaultValue.F;

        if (memberSession != null) {
            L2RCondition l2RCondition=new L2RCondition();
            l2RCondition.setAndConditions(new ConditionDetail[]{
                    new ConditionDetail(BaseEntity.BaseEntity_.id.toString(), CriteriaUtil.Operator.EQ,reservationBaseApiParamDto.getId())
            });
            l2RCondition.setOrConditions(new ConditionDetail[]{
                    new ConditionDetail(ReservationBase.ReservationBase_.rsvMobile.toString(), CriteriaUtil.Operator.EQ,memberSession.getMobile()),
                    new ConditionDetail(ReservationBase.ReservationBase_.openid.toString(), CriteriaUtil.Operator.EQ,memberSession.getOpenid()),
                    new ConditionDetail(ReservationBase.ReservationBase_.memberNo.toString(), CriteriaUtil.Operator.EQ,memberSession.getMemberNo())

            });
            QueryResult<ReservationBase> rbResult= commonService.findAllByCondition(ReservationBase.class,l2RCondition);
            ReservationDto reservationDto=new ReservationDto();
            if(rbResult.getResultlist()!=null&&rbResult.getResultlist().size()==1){
                ReservationBase rb=rbResult.getResultlist().get(0);
                ReservationPrice queryrp=new ReservationPrice();
                queryrp.setLhotelGroupCode(rb.getLhotelGroupCode());
                queryrp.setLhotelCode(rb.getLhotelCode());
                queryrp.setL2RNo(rb.getL2RNo());
                HashMap<String,String> orderBy=new HashMap<>();
                orderBy.put(ReservationPrice.ReservationPrice_.resDate.toString(),"ASC");
                QueryResult<ReservationPrice> reservationPriceResult = commonService.findAllEQ(ReservationPrice.class, queryrp, null, null, orderBy, null);
                List<ReservationPrice> reservationPriceList = reservationPriceResult.getResultlist();
                reservationDto.setReservationBaseDto(ClassConverUtil.copyPropertiesToDto(rb,ReservationBaseDto.class, false));
                if(reservationPriceList!=null&&reservationPriceList.size()>0){
                    List<ReservationPriceDto> reservationPriceDtoList=new ArrayList<>();
                    for (ReservationPrice rp:reservationPriceList){
                        if(rb.getL2RNo().equals(rp.getL2RNo())){
                            ReservationPriceDto reservationPriceDto=ClassConverUtil.copyPropertiesToDto(rp,ReservationPriceDto.class, false);
                            reservationPriceDtoList.add(reservationPriceDto);
                        }
                    }
                    reservationDto.setReservationPriceDtos(reservationPriceDtoList);
                }
                ReservationPromotion queryPromotion=new ReservationPromotion();
                queryPromotion.setLhotelGroupCode(rb.getLhotelGroupCode());
                queryPromotion.setLhotelCode(rb.getLhotelCode());
                queryPromotion.setL2RNo(rb.getL2RNo());
                QueryResult<ReservationPromotion> promotionResult = commonService.findAllEQ(ReservationPromotion.class, queryPromotion);
                reservationDto.setReservationPromotionDtos(ClassConverUtil.copyPropertiesListToDtoList(promotionResult.getResultlist(), ReservationPromotionDto.class,false));
                ReservationAccount queryRA=new ReservationAccount();
                queryRA.setLhotelGroupCode(rb.getLhotelGroupCode());
                queryRA.setLhotelCode(rb.getLhotelCode());
                queryRA.setL2RNo(rb.getL2RNo());
                ReservationAccount reservationAccount=commonService.findOneEQ(ReservationAccount.class,queryRA);
                reservationDto.setReservationAccountDto(ClassConverUtil.copyPropertiesToDto(reservationAccount, ReservationAccountDto.class,false));

                //取消退款判断
                if(BaseRateplanConstant.CANCELTYPE.CUSTOM.equals(rb.getCancelType())){
                    L2RCancelRuleDto cancelRule= JacksonUtil.jsonToBean(rb.getCancelRule(),L2RCancelRuleDto.class);
                    Date canCancelDate= DateUtil.addHours(DateUtil.parseDateNoTime(rb.getArr()),24-cancelRule.getCancelHour());
                    if(canCancelDate.getTime()>=now.getTime()){
                        cancelFlag=DefaultValue.T;
                        BigDecimal mutiply = new BigDecimal(1);
                        for (L2RCancelRuleBaseDto ruleBase : cancelRule.getL2RCancelRuleBaseDtos()) {
                            Date dateNode = DateUtil.addHours(DateUtil.parseDateNoTime(rb.getArr()), 24 - ruleBase.getHourNode());
                            if (now.getTime() <= dateNode.getTime()) {
                                if (mutiply.compareTo(ruleBase.getMultiplyValue()) > 0) {
                                    mutiply = ruleBase.getMultiplyValue();
                                }
                            }
                        }
                        ReservationPrice queryPrice = new ReservationPrice();
                        queryPrice.setLhotelGroupCode(rb.getLhotelGroupCode());
                        queryPrice.setLhotelCode(rb.getLhotelCode());
                        queryPrice.setL2RNo(rb.getL2RNo());
                        QueryResult<ReservationPrice> reservationPriceQueryResult = commonService.findAllEQ(ReservationPrice.class, queryPrice);
                        if (reservationPriceQueryResult.getResultlist() != null && reservationPriceQueryResult.getResultlist().size() > 0) {
                            if(new BigDecimal(0).compareTo(mutiply)==0) {
                                reservationDto.getReservationBaseDto().setRefundRemark("您的订单目前可以免费取消！");
                            }else if(new BigDecimal(1).compareTo(mutiply)==0) {
                                reservationDto.getReservationBaseDto().setRefundRemark("您的订单目前取消将扣除首晚房费！");
                            }else {
                                reservationDto.getReservationBaseDto().setRefundRemark("您的订单目前取消将扣除"+mutiply.multiply(new BigDecimal(100))+"%的首晚房费,金额为"+reservationAccount.getDeposit().subtract(reservationAccount.getL2RPromotion()).subtract(reservationPriceQueryResult.getResultlist().get(0).getAmountSale().multiply(mutiply)).setScale(2)+"元！");
                            }
                        }else {
                            throw new JetfireException(JetfireSysExceptionEnum.EVERYDAY_PRICE_NOT_EXIT);
                        }
                    }
                }else if(BaseRateplanConstant.CANCELTYPE.ALLOW.equals(rb.getCancelType())){
                    cancelFlag=DefaultValue.T;
                    reservationDto.getReservationBaseDto().setRefundRemark("您的订单目前可以免费取消！");
                }else if(BaseRateplanConstant.CANCELTYPE.BAN.equals(rb.getCancelType())){
                    reservationDto.getReservationBaseDto().setRefundRemark("您的订单目前不能免费取消！");
                }
                if((ReservationConstant.CONFIRMSTA.AUTOCFMD.equals(reservationDto.getReservationBaseDto().getConfirmSta())||
                        ReservationConstant.CONFIRMSTA.MANUCFMD.equals(reservationDto.getReservationBaseDto().getConfirmSta()))
                &&ReservationConstant.RESSTA.R.equals(reservationDto.getReservationBaseDto().getResSta())&&DefaultValue.T.equals(cancelFlag)){
                    reservationDto.getReservationBaseDto().setCancelFlag(DefaultValue.T);
                }else{
                    reservationDto.getReservationBaseDto().setCancelFlag(DefaultValue.F);
                }
            }
            return reservationDto;
        }else {
            return null;
        }

    }

    /**
     * 预下单
     * @param wxPayOrderApiParamDto
     * @return
     * @throws Exception
     */
    @Override
    public String l2rPreOrder(WxPayOrderApiParamDto wxPayOrderApiParamDto) throws Exception {
        String payType = wxPayOrderApiParamDto.getPayType();
        L2RAssert.stringBlank(payType,"payType is null");
        MemberSessionDto memberSession= ApiThreadLocal.getMemberSessionThreadLocal();
        Optional.ofNullable(memberSession).orElseThrow(()->new SysException(BaseSysExceptionEnum.DATA_IS_NOT_EXIST,"会员session未找到"));
        String openId=memberSession.getOpenid();
        String memberNo=memberSession.getMemberNo();
        ReservationBase queryrb=new ReservationBase();
        queryrb.setLhotelGroupCode(wxPayOrderApiParamDto.getLhotelGroupCode());
        queryrb.setLhotelCode(wxPayOrderApiParamDto.getLhotelCode());
        queryrb.setL2RNo(wxPayOrderApiParamDto.getL2RNo());
        ReservationBase rb= commonService.findOneEQ(ReservationBase.class, queryrb);
        ReservationAccount queryRA=new ReservationAccount();
        queryRA.setLhotelGroupCode(wxPayOrderApiParamDto.getLhotelGroupCode());
        queryRA.setLhotelCode(wxPayOrderApiParamDto.getLhotelCode());
        queryRA.setL2RNo(wxPayOrderApiParamDto.getL2RNo());
        ReservationAccount reservationAccount=commonService.findOneEQ(ReservationAccount.class,queryRA);

        if(ReservationConstant.CONFIRMSTA.NOTCFMD.equals(rb.getConfirmSta())&&rb.getCancelDate().getTime()>System.currentTimeMillis()){
            PrePayParamDto paramDto = new PrePayParamDto();

            paramDto.setLhotelGroupCode(wxPayOrderApiParamDto.getLhotelGroupCode());
            paramDto.setLhotelCode(wxPayOrderApiParamDto.getLhotelCode());
            paramDto.setSpBillCreateIP(BaseThreadLocal.getRemoteAddr());
            paramDto.setGoodName( rb.getHotelName()+ DefaultValue.CUT+rb.getMcdName() );
            paramDto.setOpenid(openId);
            paramDto.setOrderNo(rb.getL2RNo() );
            paramDto.setTotalFee(reservationAccount.getResRatePaySale());
            paramDto.setNotifyService(BaseConstant.ServiceCategoryConstant.JETFIRE);
            paramDto.setPayChannel(wxPayOrderApiParamDto.getPayChannel());
            paramDto.setPayType(wxPayOrderApiParamDto.getPayType());
            paramDto.setOrderType(Pay._OrderType.HOTEL);
            String prepayId=null;
            if(Objects.equals(Pay._Type.PMS.CARD,payType)){
                ReservationNmsSta queryNmsT=new ReservationNmsSta();
                queryNmsT.setLhotelGroupCode(wxPayOrderApiParamDto.getLhotelGroupCode());
                queryNmsT.setLhotelCode(wxPayOrderApiParamDto.getLhotelCode());
                queryNmsT.setL2RNo(wxPayOrderApiParamDto.getL2RNo());
                queryNmsT.setItem("CardPay");
                queryNmsT.setOperSta(DefaultValue.W);
                queryNmsT.setOperType(ReservationConstant.OPERTYPE.CREATE);
                ReservationNmsSta reservationNmsSta=commonService.findOneEQ(ReservationNmsSta.class,queryNmsT);
                if (reservationNmsSta == null) {
                    reservationService.saveReservationNmsSta(wxPayOrderApiParamDto.getLhotelGroupCode(),
                            wxPayOrderApiParamDto.getLhotelCode(),
                            rb.getL2RNo(),
                            "CardPay",
                            DefaultValue.W,
                            ReservationConstant.OPERTYPE.CREATE);
                }
                if(StringUtil.isBlank(rb.getCrsNo())){
                    this.savePmsReservation(rb);
                }
                PmsReservationOptionParamDto pmsReservationOptionParamDto=new PmsReservationOptionParamDto();
                pmsReservationOptionParamDto.setPbChannel(rb.getPbChannel());
                pmsReservationOptionParamDto.setResType(rb.getResType());
                PmsReservationOptionDto pmsReservationOptionDto= pmsReservationOptionFeignService.getPmsReservationOption(pmsReservationOptionParamDto.paramToMap()).getResultInfo();
                paramDto.setMemberNo(memberNo);
                if(pmsReservationOptionDto.getTaCodeMap()!=null){
                    paramDto.setTaCode(pmsReservationOptionDto.getTaCodeMap().get(payType));
                }
                prepayId=pmsReservationFeignService.memberCardPrePay(paramDto).getResultInfo();
                ReservationNmsSta queryNms=new ReservationNmsSta();
                queryNms.setLhotelGroupCode(wxPayOrderApiParamDto.getLhotelGroupCode());
                queryNms.setLhotelCode(wxPayOrderApiParamDto.getLhotelCode());
                queryNms.setL2RNo(wxPayOrderApiParamDto.getL2RNo());
                queryNms.setItem(BaseConstant.ServiceCategoryConstant.TRAILBREAKER);
                queryNms.setOperSta(DefaultValue.W);
                queryNms.setOperType(ReservationConstant.OPERTYPE.CREATE);
                commonService.deleteAllEQ(ReservationNmsSta.class, queryNms);
            }else {
                //订单处理状态（支付）
                ReservationNmsSta queryNmsT=new ReservationNmsSta();
                queryNmsT.setLhotelGroupCode(wxPayOrderApiParamDto.getLhotelGroupCode());
                queryNmsT.setLhotelCode(wxPayOrderApiParamDto.getLhotelCode());
                queryNmsT.setL2RNo(wxPayOrderApiParamDto.getL2RNo());
                queryNmsT.setItem(BaseConstant.ServiceCategoryConstant.TRAILBREAKER);
                queryNmsT.setOperSta(DefaultValue.W);
                queryNmsT.setOperType(ReservationConstant.OPERTYPE.CREATE);
                ReservationNmsSta reservationNmsSta=commonService.findOneEQ(ReservationNmsSta.class,queryNmsT);
                if (reservationNmsSta == null) {
                    reservationService.saveReservationNmsSta(wxPayOrderApiParamDto.getLhotelGroupCode(),
                            wxPayOrderApiParamDto.getLhotelCode(),
                            rb.getL2RNo(),
                            BaseConstant.ServiceCategoryConstant.TRAILBREAKER,
                            DefaultValue.W,
                            ReservationConstant.OPERTYPE.CREATE);
                }
                prepayId=prepayFeignService.unifiedorderSign(paramDto).getResultInfo().getL2rPrepayId();
                ReservationNmsSta queryNms=new ReservationNmsSta();
                queryNms.setLhotelGroupCode(wxPayOrderApiParamDto.getLhotelGroupCode());
                queryNms.setLhotelCode(wxPayOrderApiParamDto.getLhotelCode());
                queryNms.setL2RNo(wxPayOrderApiParamDto.getL2RNo());
                queryNms.setItem("CardPay");
                queryNms.setOperSta(DefaultValue.W);
                queryNms.setOperType(ReservationConstant.OPERTYPE.CREATE);
                commonService.deleteAllEQ(ReservationNmsSta.class, queryNms);
            }
            return prepayId;
        }else {
            throw new JetfireException(JetfireSysExceptionEnum.L2R_PRE_ORDER_ERROR);
        }
    }

    private void savePmsReservation(ReservationBase reservationBase) throws Exception {
        String lhotelGroupCode=reservationBase.getLhotelGroupCode();
        String lhotelCode=reservationBase.getLhotelCode();
        String l2rNo=reservationBase.getL2RNo();
        ReservationPrice queryPrice=new ReservationPrice();
        queryPrice.setLhotelGroupCode(lhotelGroupCode);
        queryPrice.setLhotelCode(lhotelCode);
        queryPrice.setL2RNo(l2rNo);
        QueryResult<ReservationPrice> priceResult = commonService.findAllEQ(ReservationPrice.class, queryPrice);
        List<ReservationPriceDto> reservationPriceDtos = ClassConverUtil.copyPropertiesListToDtoList(priceResult.getResultlist(), ReservationPriceDto.class, false);

        GcOrderCoupon queryCoupon=new GcOrderCoupon();
        queryCoupon.setLhotelGroupCode(lhotelGroupCode);
        queryCoupon.setLhotelCode(lhotelCode);
        queryCoupon.setL2RNo(l2rNo);
        QueryResult<GcOrderCoupon> couponResult = commonService.findAllEQ(GcOrderCoupon.class, queryCoupon);
        List<GcOrderCouponDto> gcOrderCouponDtos = ClassConverUtil.copyPropertiesListToDtoList(couponResult.getResultlist(), GcOrderCouponDto.class, false);

        ReservationParamDto reservationParamDto=new ReservationParamDto();
        reservationParamDto.setOperType(ReservationConstant.OPERTYPE.CREATE);
        reservationParamDto.setReservationBase(ClassConverUtil.copyPropertiesToDto(reservationBase,ReservationBaseDto.class, false));
        reservationParamDto.setReservationPriceDtos(reservationPriceDtos);
        reservationParamDto.setGcOrderCoupons(gcOrderCouponDtos);
        pmsReservationFeignService.savePmsReservation(reservationParamDto);
    }
}
